package com.blobfish.fiction.book.validator;

import com.blobfish.fiction.book.constant.BookMessageEnum;
import com.blobfish.fiction.common.base.validator.BaseValidator;
import com.blobfish.fiction.common.model.Book;
import com.blobfish.fiction.common.util.ValiMessageUtil;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * 新增小说验证器
 * @author huangbo
 */
public class AddBookValidator extends BaseValidator {
    @Override
    protected void validate(Controller controller) {
        validateRequiredString("name", BookMessageEnum.BOOK_NAME_NOT_BLANK.getId(), "小说名称不能为空!");
        validateRequiredString("bookNo", BookMessageEnum.BOOK_NO_NOT_BLANK.getId(), "小说编号不能为空!");
    }

    @Override
    protected void handleError(Controller controller) {
        controller.getAttrNames();
        controller.keepModel(Book.class);
        super.handleError(controller);
    }
}
